var userData;
const app = getApp()

Page({
  data: {
    userName: "用户名",
    userImg: "",
  },
  userOffLine: function () {
    wx.showActionSheet({
      alertText: "确定退出登录吗?",
      itemList: ['退出登录'],
      itemColor: "#FA5151",
      success: function (res) {
        console.log('userOffLine')
      }
    })
  },
  userCollections: function () {
    wx.navigateTo({
      url: '/users/myfavorites/myfavorites',
    })
  },
  userDownloads: function () {
    wx.navigateTo({
      url: '/users/mydownload/mydownload',
    })
  },
  userUploads: function () {
    wx.navigateTo({
      url: '/users/myupload/myupload',
    })
  },
  userDemand: function () {
    wx.navigateTo({
      url: '/users/mydemands/mydemands',
    })
  },
  userInfo: function(){
    wx.navigateTo({
      url: `/users/userinfo/userinfo`,
    })
  },
  userMsg: function(){
    wx.navigateTo({
      url: '/users/mymsg/mymsg',
    })
  },
  async onShow() {
    let that = this
    app.slideRightShow(that, 'fadein', 0, 1)
    let res = await app.get('user/')
    this.setData({
      userImg: app.globalData.url + res.data.avatar,
      userName: res.data.nickname
    })
  },
  onHide(){
    let that = this
    app.slideRightShow(that, 'fadein', -150, 0)
  }
})